﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using TyMES.Model.BaseInformation;
using TyMES.Model;

namespace TyMES.ViewModel.BaseInformation.Order_ModelVMs
{
    public partial class Order_ModelListVM : BasePagedListVM<Order_Model_View, Order_ModelSearcher>
    {
        
        protected override IEnumerable<IGridColumn<Order_Model_View>> InitGridHeader()
        {
            return new List<GridColumn<Order_Model_View>>{
                
                this.MakeGridHeader(x => x.Order_Model_orderType).SetTitle(@Localizer["Page.工单类型"].Value),
                this.MakeGridHeader(x => x.Order_Model_orderCode).SetTitle(@Localizer["Page.工单编号"].Value),
                this.MakeGridHeader(x => x.Order_Model_orderQty).SetTitle(@Localizer["Page.工单数量"].Value),
                this.MakeGridHeader(x => x.Order_Model_order_Status).SetTitle(@Localizer["Page.工单状态"].Value),
                this.MakeGridHeader(x => x.Order_Model_materialCode).SetTitle(@Localizer["Page.虚拟物料编码"].Value),
                this.MakeGridHeader(x => x.Order_Model_materialId).SetTitle(@Localizer["Page.虚拟物料ID"].Value),
                this.MakeGridHeader(x => x.Order_Model_materialName).SetTitle(@Localizer["Page.虚拟物料名称"].Value),
                this.MakeGridHeader(x => x.Order_Model_materialVersion).SetTitle(@Localizer["Page.虚拟物料版本"].Value),
                this.MakeGridHeader(x => x.Order_Model_scheduleCode).SetTitle(@Localizer["Page.分工单编码"].Value),
                this.MakeGridHeader(x => x.Order_Model_scheduleQty).SetTitle(@Localizer["Page.分工单数量"].Value),
                this.MakeGridHeader(x => x.Order_Model_scheduleEditTime).SetTitle(@Localizer["Page.分工单编辑时间"].Value),
                this.MakeGridHeader(x => x.Order_Model_scheduleId).SetTitle(@Localizer["Page.分工单ID"].Value),
                this.MakeGridHeader(x => x.Order_Model_scheduleStationId).SetTitle(@Localizer["Page.分工单站号"].Value),
                this.MakeGridHeader(x => x.Order_Model_MOrderStatus).SetTitle(@Localizer["Page.分工单状态"].Value),
                this.MakeGridHeader(x => x.Order_Model_workshopCode).SetTitle(@Localizer["Page.车间编码"].Value),
                this.MakeGridHeader(x => x.Order_Model_workshopName).SetTitle(@Localizer["Page.车间名称"].Value),
                this.MakeGridHeader(x => x.Order_Model_lineCode).SetTitle(@Localizer["Page.产线号"].Value),
                this.MakeGridHeader(x => x.Order_Model_lineName).SetTitle(@Localizer["Page.产线名称"].Value),
                this.MakeGridHeader(x => x.Order_Model_stationCode).SetTitle(@Localizer["Page.上线工位编码"].Value),
                this.MakeGridHeader(x => x.Order_Model_stationName).SetTitle(@Localizer["Page.上线工位名称"].Value),
                this.MakeGridHeader(x => x.Order_Model_equipmentCode).SetTitle(@Localizer["Page.设备编码"].Value),
                this.MakeGridHeader(x => x.Order_Model_startTime).SetTitle(@Localizer["Page.开始时间"].Value),
                this.MakeGridHeader(x => x.Order_Model_endTime).SetTitle(@Localizer["Page.结束时间"].Value),
                this.MakeGridHeader(x => x.Order_Model_factoryCode).SetTitle(@Localizer["Page.工厂编码"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<Order_Model_View> GetSearchQuery()
        {
            var query = DC.Set<Order_Model>()
                
                .CheckContain(Searcher.OrderType, x=>x.OrderType)
                .CheckContain(Searcher.OrderCode, x=>x.OrderCode)
                .CheckContain(Searcher.OrderQty, x=>x.OrderQty)
                .CheckEqual(Searcher.Order_Status, x=>x.Order_Status)
                .CheckContain(Searcher.MaterialCode, x=>x.MaterialCode)
                .CheckContain(Searcher.MaterialId, x=>x.MaterialId)
                .CheckContain(Searcher.MaterialName, x=>x.MaterialName)
                .CheckContain(Searcher.MaterialVersion, x=>x.MaterialVersion)
                .CheckContain(Searcher.ScheduleCode, x=>x.ScheduleCode)
                .CheckContain(Searcher.ScheduleQty, x=>x.ScheduleQty)
                .CheckContain(Searcher.ScheduleEditTime, x=>x.ScheduleEditTime)
                .CheckContain(Searcher.ScheduleId, x=>x.ScheduleId)
                .CheckContain(Searcher.ScheduleStationId, x=>x.ScheduleStationId)
                .CheckContain(Searcher.MOrderStatus, x=>x.MOrderStatus)
                .CheckContain(Searcher.WorkshopCode, x=>x.WorkshopCode)
                .CheckContain(Searcher.WorkshopName, x=>x.WorkshopName)
                .CheckContain(Searcher.LineCode, x=>x.LineCode)
                .CheckContain(Searcher.LineName, x=>x.LineName)
                .CheckContain(Searcher.StationCode, x=>x.StationCode)
                .CheckContain(Searcher.StationName, x=>x.StationName)
                .CheckContain(Searcher.EquipmentCode, x=>x.EquipmentCode)
                .CheckContain(Searcher.StartTime, x=>x.StartTime)
                .CheckContain(Searcher.EndTime, x=>x.EndTime)
                .CheckContain(Searcher.FactoryCode, x=>x.FactoryCode)
                .Select(x => new Order_Model_View
                {
				    ID = x.ID,
                    
                    Order_Model_orderType = x.OrderType,
                    Order_Model_orderCode = x.OrderCode,
                    Order_Model_orderQty = x.OrderQty,
                    Order_Model_order_Status = x.Order_Status,
                    Order_Model_materialCode = x.MaterialCode,
                    Order_Model_materialId = x.MaterialId,
                    Order_Model_materialName = x.MaterialName,
                    Order_Model_materialVersion = x.MaterialVersion,
                    Order_Model_scheduleCode = x.ScheduleCode,
                    Order_Model_scheduleQty = x.ScheduleQty,
                    Order_Model_scheduleEditTime = x.ScheduleEditTime,
                    Order_Model_scheduleId = x.ScheduleId,
                    Order_Model_scheduleStationId = x.ScheduleStationId,
                    Order_Model_MOrderStatus = x.MOrderStatus,
                    Order_Model_workshopCode = x.WorkshopCode,
                    Order_Model_workshopName = x.WorkshopName,
                    Order_Model_lineCode = x.LineCode,
                    Order_Model_lineName = x.LineName,
                    Order_Model_stationCode = x.StationCode,
                    Order_Model_stationName = x.StationName,
                    Order_Model_equipmentCode = x.EquipmentCode,
                    Order_Model_startTime = x.StartTime,
                    Order_Model_endTime = x.EndTime,
                    Order_Model_factoryCode = x.FactoryCode,
                })
                .OrderBy(x => x.ID);
            return query;
        }

        
    }
    public class Order_Model_View: Order_Model
    {
        
        public string Order_Model_orderType { get; set; }
        public string Order_Model_orderCode { get; set; }
        public string Order_Model_orderQty { get; set; }
        public OrderStatusEnum? Order_Model_order_Status { get; set; }
        public string Order_Model_materialCode { get; set; }
        public string Order_Model_materialId { get; set; }
        public string Order_Model_materialName { get; set; }
        public string Order_Model_materialVersion { get; set; }
        public string Order_Model_scheduleCode { get; set; }
        public string Order_Model_scheduleQty { get; set; }
        public string Order_Model_scheduleEditTime { get; set; }
        public string Order_Model_scheduleId { get; set; }
        public string Order_Model_scheduleStationId { get; set; }
        public string Order_Model_MOrderStatus { get; set; }
        public string Order_Model_workshopCode { get; set; }
        public string Order_Model_workshopName { get; set; }
        public string Order_Model_lineCode { get; set; }
        public string Order_Model_lineName { get; set; }
        public string Order_Model_stationCode { get; set; }
        public string Order_Model_stationName { get; set; }
        public string Order_Model_equipmentCode { get; set; }
        public string Order_Model_startTime { get; set; }
        public string Order_Model_endTime { get; set; }
        public string Order_Model_factoryCode { get; set; }

    }

}